#pragma once
#include"RBTree.h"
namespace jz 
{
	template<class K> 
	class set
	{
		struct set__keyoft
		{
		public:
			const K& operator()(const K& key)
			{
				return key;
			}
		};

	public:
		typedef typename RBTree<K, const K, set__keyoft>::iterator iterator;
		typedef typename RBTree<K, const K, set__keyoft>::const_iterator const_iterator;
		typedef typename RBTree<K, const K, set__keyoft>::reverse_iterator reverse_iterator;
		typedef typename RBTree<K, const K, set__keyoft>::const_reverse_iterator const_reverse_iterator;

		iterator begin()
		{
			return _t.begin();
		}
		iterator end()
		{
			return _t.end();
		}
		reverse_iterator rbegin()
		{
			return _t.rbegin();
		}
		reverse_iterator rend()
		{
			return _t.rend();
		}
		pair<iterator,bool> insert(const K& key)
		{
			return _t.Inset(key);
		}
	private:
		RBTree<K, const K, set__keyoft> _t;
	};
	void test_set()
	{
		set<int> s;
		int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
		for (auto e : a)
		{
			s.insert(e);
		}
		set<int>::reverse_iterator it = s.rend();
		while (it != s.rbegin())
		{
			//if(*it % 2 == 0)
			//	*it += 100;
			

			std::cout << *it << " ";
			--it;

		}
		cout << endl;
	}
}

	
